package com.zrh.jsd.service.studydemo.threadpool;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.*;

public class CompleteTest {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        System.out.println(getUserInfo());
    }
    public static Integer getUserInfo() throws InterruptedException, ExecutionException {
        ExecutorService executor = Executors.newCachedThreadPool();

        CompletableFuture userFuture = CompletableFuture.supplyAsync(() -> a(), executor);
        System.out.println("11111111111");
        System.out.println(userFuture.get());
        System.out.println("22222222222222222");
        return 123;
    }

    private static boolean a() {
        try {
            TimeUnit.SECONDS.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return true;
    }
}
